<div class="SipeiMain_r fr">
    <h2 class="clearfix fonts_18 height45 fontc_444"><?php echo $this->title; ?></h2>
    <div class="clearfix back_bgf border_3 border_c pt20 pr30 pb20 height32 fontc_666">
        <form action="<?php echo $this->createUrl('/role/default/role_user'); ?>" method="get" name="search">
            <table>
                <tbody>
                    <tr>
                        <td align="right" width="88" class="pt10 pr3 pb10">用户登录名：</td>
                        <td width="120"><input type="text" value="<?php echo isset($s['username'])?$s['username']:''; ?>" name="username" class="pt6 pr5 pb6 pl6 border_3 border_c fontc_666 w100" /></td>
                        <td align="right" width="75" class="pt10 pr3 pb10">用户描述：</td>
                        <td width="120"><input type="text" value="<?php echo isset($s['comment'])?$s['comment']:''; ?>" name="comment" class="pt6 pr5 pb6 pl6 border_3 border_c fontc_666 w100" /></td>
                        <td align="right" width="75" class="pt10 pr3 pb10">所属科目：</td>
                        <td width="120">                            
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                                <span class="fl select_shelter select_shelter2">
                                    <select class="fl fontc_666" name="subject">
                                        <option value="0">请选择</option>
                                        <?php foreach ($subject_object as $sV): ?>
                                            <option value="<?php echo $sV['subject_id']; ?>" <?php if ($sV['subject_id'] == $s['subject']): ?>selected<?php endif; ?>><?php echo $sV['subject_name']; ?></option>
                                        <?php endforeach; ?>
                                    </select>
                                </span>
                            </span>
                        </td>
                        <td width="160" class="pt10 pb10 text_right">
                            <input type="submit" value="查询" class="b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" />
                        </td>
                    </tr>
                    <tr>
                        <td  align="right"class="pt10 pr3 pb10">所属角色：</td>
                        <td>
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3" style="width:100px;">
                                <span class="fl select_shelter select_shelter2" >
                                    <select class="fl fontc_666" name="role">
                                        <option value="0">请选择</option>
                                        <?php foreach ($roleObject as $rVal): ?>
                                            <option value="<?php echo $rVal['role_id']; ?>" <?php if ($rVal['role_id'] == $s['role']): ?>selected<?php endif; ?>><?php echo $rVal['role_name']; ?></option>
                                        <?php endforeach; ?>
                                    </select>
                                </span>
                            </span>
                        </td>
                        <td align="right" class="pt10 pr3 pb10">所属学校：</td>
                        <td>
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                                <span class="fl select_shelter select_shelter2">
                                    <select class="fl fontc_666" name="school">
                                        <option value="0">请选择</option>
                                        <?php foreach ($school_object as $sVal): ?>
                                            <option value="<?php echo $sVal['school_id']; ?>" <?php if ($sVal['school_id'] == $s['school']): ?>selected<?php endif; ?>><?php echo $sVal['school_name']; ?></option>
                                        <?php endforeach; ?>
                                    </select>
                                </span>
                            </span>
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </div>
    <div class="clearfix back_bgf border_c mt15 pt20 pb20">
        <div class="clearfix pb20 pl30">
            <input type="button" value="新增" style="margin-right:30px;" onclick="add()" class="fr b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 mr10 cursor" />
            <input type="button" value="导出Excel" onclick="importExcel();" class="b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" />
        </div>
        <table class="height40">
            <thead class="back_bgf5 fontc_666">
                <tr>
                    <th width="100" align="center" class="m_hr_t m_hr_b">用户登录名</th>
                    <th width="120" align="center" class="m_hr_t m_hr_b">所属角色</th>
                    <th width="150" align="center" class="m_hr_t m_hr_b">所属学校</th>
                    <th width="125" align="center" class="m_hr_t m_hr_b">所属科目</th>
                    <th width="150" align="center" class="m_hr_t m_hr_b">用户描述</th>
                    <th width="65" align="center" class="m_hr_t m_hr_b">生效</th>
                    <th width="90" align="center" class="m_hr_t m_hr_b">操作</th>
                </tr>
            </thead>
            <tbody class="fontc_444">
            <?php if (!empty($data)): ?>
                <?php foreach ($data as $value): ?>
                <tr>
                    <td align="center" class="m_hr_b"><?php echo $value['username']; ?></td>
                    <td align="center" class="m_hr_b"><?php echo $roleObject[$value['role_id']]['role_name']; ?></td>
                    <td align="center" class="m_hr_b height20 pt8 pb8"><?php echo $value['school_name']; ?></td>
                    <td align="center" class="m_hr_b height20 pt8 pb8"><?php echo $value['subject_name']; ?></td>
                    <td align="center" class="m_hr_b height20 pt8 pb8"><?php echo $value['comment']; ?></td>
                    <td align="center" class="m_hr_b">
                        <input type="checkbox" <?php if ($value['status']): ?>checked<?php endif; ?> disabled>
                    </td>
                    <td align="center" class="m_hr_b">
                        <?php if(($role_id == 1) || ($value['id'] == $user_id)): ?>
                        <a href="javascript:;" onclick="edit(<?php echo $value['id']; ?>)" title="编辑" class="mr10">
                            <img src="/themes/default/images/Sipei/edit.png" />
                        </a>
                        <a href="javascript:;" title="删除" onclick="del(<?php echo $value['id']; ?>,$(this),<?php echo $value['status'];?>)">
                            <img src="/themes/default/images/Sipei/delate.png" />
                        </a>
                        <?php endif; ?>
                    </td>
                </tr>
                <?php endforeach; ?>
            <?php else: ?>
                <tr><td colspan="8" align="center" class="m_hr_b">暂时没有用户数据</td></tr>
            <?php endif; ?>
            </tbody>
        </table>
         <?php $this->renderPartial('//partial/partial_pager', array('pages' => $pages, "url" => $pageUrl)); ?>
    </div>
</div>
<script>
    var sj = '<?php echo time(); ?>';
    function edit(id) {
        api = $.dialog({
            id: 'testID2',
            lock: true,
            fixed: true,
            title: "编辑",
            width: 580,
            height: 470,
            max: false,
            min: false
        });
        
        $.get('/user/default/update', {uid: id,time:sj}, function(html) {
            api.content(html);
        });
    }

    function add() {

        api = $.dialog({
            id: 'testID2',
            lock: true,
            fixed: true,
            title: "新增",
            width: 580,
            height: 470,
            max: false,
            min: false
        });
        $.get('/user/default/add', {}, function(html) {
            api.content(html);
        });
    }

    function del(id,that,is_del) {
        
        $.dialog.confirm('确定删除吗',function(){
            $.get('/user/default/delete', {id: id}, function(html) {
                if (html == 1) {
                    that.parents('tr').remove();
                }else{
                    alert('删除失败');
                }
            });
        });
    }
               
    function importExcel(){
        location.href = "<?php echo $this->createUrl('/user/default/importexcel'); ?>"; 
    }
                
</script>